<?php
include "general_include.php";
include "checklogin.php";
include "top.php";
//include "left.php";

$messg = $_REQUEST['messg'];

function findlanguage($language_id)
{
     if($language_id=='')
			return false;
			
		$SelectTypeSql = "SELECT language_name FROM ".TABLEPREFIX."_language WHERE language_id=$language_id";
		$SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
		return $SelectType[0];
}	

$Sqluser = "SELECT * FROM ".TABLEPREFIX."_user where user_id='".$_SESSION['user_id']."'";
$userArr = $UserManagerObjAjax->GetRecords("Row",$Sqluser);
$pass_len = strlen($userArr['password']);

$userArr['type_id'] = $_SESSION['user_type']; 

$Sqltype = "SELECT * FROM ".TABLEPREFIX."_user_type_user_relation WHERE user_id='".$_SESSION['user_id']."'";
$typeArr = $UserManagerObjAjax->GetRecords("All",$Sqltype);
$Numtype = count($typeArr);
$utype='';
for($t=0;$t<$Numtype;$t++)
{
  
   if($typeArr[$t]['user_type_id']==1)
      $utype= 'Coach ,';
   if($typeArr[$t]['user_type_id']==3)
      $utype.= 'Training Partner ,';
   if($typeArr[$t]['user_type_id']==2)
       $utype.= 'Student ,';	  

}
  $userArr['type'] = substr($utype,0,-2); 
for($p=0; $p<$pass_len;$p++)
{
   $pass_word .='*';
}
$Sqlcoun = "SELECT * FROM ".TABLEPREFIX."_country where country_id='".$userArr['country']."'";
$CounArr =  $UserManagerObjAjax->GetRecords("Row",$Sqlcoun);

$Sqlcity = "SELECT * FROM ".TABLEPREFIX."_cities where city_id='".$userArr['city']."'";
$CityArr =  $UserManagerObjAjax->GetRecords("Row",$Sqlcity);


$userArr['pass_word']=$pass_word;
$userArr['user_about'] = stripslashes($userArr['user_about']);
$userArr['desc'] = stripslashes($userArr['description']);
$userArr['date_of_birth'] = date_format_display($userArr['date_of_birth']);  
$userArr['country'] = $CounArr['country_name'];
$userArr['city'] = $CityArr['city_key'];
$Clanguage = explode(",",$userArr['language_ids']);
	$language='';
	for($l=0;$l<count($Clanguage);$l++)
	{
	   if($Clanguage[$l]<>'')
	    $language .=findlanguage($Clanguage[$l]).' , ';
	}
	$userArr['language']=substr($language,0,-2); 


if($messg==1)
   $msg = "Password Change successfully";
if($messg==2)  
   $msg =  "Profile edited successfully";
 
$smarty->assign('msg',$msg);   
$smarty->assign('is_coach',$is_coach);
$smarty->assign('is_partner',$is_partner);
$smarty->assign('userArr',$userArr);
$smarty->assign('typeArr',$typeArr);
$smarty->display('profile.tpl');
include "footer.php";
?>